package com.wang.data.server;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class NettyServerListener implements ServletContextListener {

	@Autowired
	private WServer nettyServer;

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		Thread thread = new Thread(new NettyServerThread());
		// 启动netty服务
		thread.start();
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
     System.out.println("contextDestroyed");
	}

	private class NettyServerThread implements Runnable {
		@Override
		public void run() {
			nettyServer.run();
		}
	}

}
